import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { OpenThrTouter, OpenSelection, DelDataButton } from '../Common/options'

export const DepartmentUsers = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <OpenThrTouter
                title="新增人员"
                type="primary"
                icon="add"
                twoTitle="添加人员"
                modal="SelectModal"
                width={1200}
                OptionsEvent={OptionsEvent}
                other={{ page: 'DepartmentUsers', actionRef }}
            />,
            <OpenSelection
                OptionsEvent={OptionsEvent}
                title="批量删除"
                type="primary"
                danger
                data={{
                    type: 'SelectionDelete',
                    url: 'posDepartmentUsersBatchRemove',
                }}
            />,
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'DepartmentUsers' },
            commonTableList.uuid,
            {
                dataIndex: 'departmentName',
                title: '部门名称',
                valueType: 'input',
                width: 240,
            },
            {
                dataIndex: 'userName',
                title: '登录账号',
                valueType: 'input',
                width: 240,
                hideInSearch: true,
            },
            {
                dataIndex: 'userFullName',
                title: '姓名',
                valueType: 'input',
                width: 240,
            },
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 80,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
